package com.masterclient.app.modules.goods

import android.content.Intent
import android.graphics.Paint
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.masterclient.app.R
import com.eoner.baselibrary.bean.goods.GoodDetailBean
import com.eoner.baselibrary.utils.GlideUtil
import com.eoner.baselibrary.utils.Utils
import com.masterclient.app.modules.goods.newpage.activity.NewCommodityDetailActivity

/**
 * 作者：sean
 * 创建时间：2018/4/24 16:13
 * 功能说明：
 */
class GoodsDetailRemAdapter:BaseQuickAdapter<GoodDetailBean.DataBean.ShSellerRecomProductsBean,BaseViewHolder>(R.layout.item_goodsdetail_rem) {

    override fun convert(helper: BaseViewHolder, item: GoodDetailBean.DataBean.ShSellerRecomProductsBean) {
        helper.setText(R.id.tv_name, item.sh_nameX)
        if(!TextUtils.isEmpty(item.sh_image)){
            //App.picasso.load(item.sh_image).into(helper.getView<ImageView>(R.id.iv_good))
            GlideUtil.displayRoundImage(mContext,item.sh_image,helper.getView<ImageView>(R.id.iv_good),7,R.mipmap.defaults)
        }

        Utils.set_price_style(helper.getView(R.id.tv_price_now),"¥"+ item.sh_show_priceX);
//        helper.setText(R.id.tv_price_now,"¥"+ item.sh_show_priceX)
        Utils.setDin(helper.getView(R.id.tv_price_now),mContext)
        helper.setText(R.id.tv_price_older,"¥"+item.sh_line_priceX)
        helper.getView<TextView>(R.id.tv_price_older).paintFlags = Paint.STRIKE_THRU_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG

//        if (0.0 == java.lang.Double.valueOf(item.sh_partner_commissionX)) {
//            helper.getView<LinearLayout>(R.id.ll_user).visibility = View.VISIBLE
//            helper.getView<LinearLayout>(R.id.ll_earn).visibility = View.GONE
//        } else {
//            helper.setText(R.id.tv_price,"¥" + item.sh_show_priceX)
//            helper.setText(R.id.tv_money_earn,"赚" + item.sh_partner_commissionX)
//            helper.getView<LinearLayout>(R.id.ll_user).visibility = View.GONE
//            helper.getView<LinearLayout>(R.id.ll_earn).visibility = View.VISIBLE
//        }

        helper.getView<LinearLayout>(R.id.ll_main)?.setOnClickListener(View.OnClickListener {
            val intent = Intent()
            intent.setClass(mContext, NewCommodityDetailActivity::class.java)
            val bundle = Bundle()
            bundle.putString("id",item.sh_idX)
            intent.putExtras(bundle)
            mContext.startActivity(intent)
        })
    }

}